package com.java.study.invoker.enreka.interceptor;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpRequest;

import java.net.URI;
import java.net.URISyntaxException;

public class RestHttpRequest implements HttpRequest {
    private HttpRequest sourceRequest;

    public RestHttpRequest(HttpRequest sourceRequest) {
        this.sourceRequest = sourceRequest;
    }

    public HttpHeaders getHeaders() {
        return sourceRequest.getHeaders();
    }

    public HttpMethod getMethod() {
        return sourceRequest.getMethod();

    }

    public URI getURI() {

        try {
            String oldUri = sourceRequest.getURI().toString();
            URI newUri = new URI("http://www.baidu.com");
            return newUri;
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }
        return sourceRequest.getURI();

    }
}
